/*************************************************************************
	> File Name: B2075.cpp
	> Author: 
	> Mail: 
	> Created Time: 
 ************************************************************************/
#include <iostream>
#include <cstdio>

using namespace std;

int fastPower(long long a, long long b, int p) {
    int result = 1;
    while (b) {
        if (b & 1) result = ((result % p) * (a % p)) % p;
        a = ((a % p) * (a % p)) % p;
        b >>= 1;
    }
    return result;
}

int main() {
    int a, b;
    cin >> a >> b;
    printf("%03d\n", fastPower(a, b, 1000));
    return 0;
}
